1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module shumate.MapSourceRegistry; 26 27 private import gio.ListModelIF; 28 private import gio.ListModelT; 29 private import glib.ConstructionException; 30 private import glib.Str; 31 private import gobject.ObjectG; 32 private import shumate.MapSource; 33 private import shumate.c.functions; 34 public import shumate.c.types; 35 36 37 /** 38 * This object allows you to hold [class@MapSource] instances, you can access a 39 * default set of sources with [method@MapSourceRegistry.populate_defaults]. 40 * 41 * It conveniently implements [iface@Gio.ListModel] to easily integrate with it. 42 */ 43 public class MapSourceRegistry : ObjectG, ListModelIF 44 { 45 /** the main Gtk struct */ 46 protected ShumateMapSourceRegistry* shumateMapSourceRegistry; 47 48 /** Get the main Gtk struct */ 49 public ShumateMapSourceRegistry* getMapSourceRegistryStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return shumateMapSourceRegistry; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)shumateMapSourceRegistry; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (ShumateMapSourceRegistry* shumateMapSourceRegistry, bool ownedRef = false) 66 { 67 this.shumateMapSourceRegistry = shumateMapSourceRegistry; 68 super(cast(GObject*)shumateMapSourceRegistry, ownedRef); 69 } 70 71 // add the ListModel capabilities 72 mixin ListModelT!(ShumateMapSourceRegistry); 73 74 /** 75 * Create a new #ShumateMapSourceRegistry. 76 * 77 * Returns: a newly created #ShumateMapSourceRegistry 78 * 79 * Throws: ConstructionException GTK+ fails to create the object. 80 */ 81 public this(bool defaults = false) 82 { 83 ShumateMapSourceRegistry* __p; 84 85 if (!defaults) __p = shumate_map_source_registry_new(); 86 else __p = shumate_map_source_registry_new_with_defaults(); 87 88 if(__p is null) 89 { 90 throw new ConstructionException("null returned by new"); 91 } 92 93 this(cast(ShumateMapSourceRegistry*) __p, true); 94 } 95 96 /** 97 */ 98 99 /** */ 100 public static GType getType() 101 { 102 return shumate_map_source_registry_get_type(); 103 } 104 105 /** 106 * Adds the #ShumateMapSource to the #ShumateMapSourceRegistry 107 * 108 * Params: 109 * mapSource = a #ShumateMapSource 110 */ 111 public void add(MapSource mapSource) 112 { 113 shumate_map_source_registry_add(shumateMapSourceRegistry, (mapSource is null) ? null : mapSource.getMapSourceStruct()); 114 } 115 116 /** 117 * Find the #ShumateMapSource with the corresponding id 118 * 119 * Params: 120 * id = the id of the #ShumateMapSource 121 * 122 * Returns: the #ShumateMapSource or %NULL if no 123 * map source has been found 124 */ 125 public MapSource getById(string id) 126 { 127 auto __p = shumate_map_source_registry_get_by_id(shumateMapSourceRegistry, Str.toStringz(id)); 128 129 if(__p is null) 130 { 131 return null; 132 } 133 134 return ObjectG.getDObject!(MapSource)(cast(ShumateMapSource*) __p); 135 } 136 137 /** 138 * Populates the #ShumateMapSourceRegistry with a default set of sources. 139 */ 140 public void populateDefaults() 141 { 142 shumate_map_source_registry_populate_defaults(shumateMapSourceRegistry); 143 } 144 145 /** 146 * Removes the corresponding #ShumateMapSource from the registry. 147 * If the source doesn't exist in the registry, this function does nothing. 148 * 149 * Params: 150 * id = a #ShumateMapSource id 151 */ 152 public void remove(string id) 153 { 154 shumate_map_source_registry_remove(shumateMapSourceRegistry, Str.toStringz(id)); 155 } 156 }